package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.Arrays;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;


public class LayerPropertiesPanel extends JPanel{

	private BoxLayout superLay = new BoxLayout(this, BoxLayout.Y_AXIS);
	
	private String [] connectionOptions = {"Grid", "Flat"};
	private JComboBox<String []> connectionTypes = new JComboBox(connectionOptions);
	private JTextField x = new JTextField(3);
	private JTextField y = new JTextField(3);
	private JTextField z = new JTextField(3);
	private JTextField dimX = new JTextField(3);
	private JTextField dimY = new JTextField(3);
	private JTextField dimZ = new JTextField(3);
	private JButton collisionCheck = new JButton("Check");
	private JTextField percentEx = new JTextField(3);
	private JTextField numNeurons = new JTextField(3);
	private JPanel positionPanel = new JPanel();
	
	private LIFPropertiesPanel exPanel = new LIFPropertiesPanel();
	private LIFPropertiesPanel inPanel = new LIFPropertiesPanel();
	
	
	public LayerPropertiesPanel(){

		initializeLayout();
	}
	
	
	public void initializeLayout() {
		this.setLayout(superLay);
		
		JTabbedPane ExInPane = new JTabbedPane();	
		ExInPane.addTab("Excitatory", exPanel);
		ExInPane.addTab("Inhibitory", inPanel);	
		this.add(ExInPane, superLay);			
		
		JSeparator sep = new JSeparator();
		sep.setBackground(Color.LIGHT_GRAY);
		this.add(sep, superLay);
		
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.anchor = GridBagConstraints.WEST;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.weightx = 1;
		gbc.insets = new Insets(10, 10, 0, 10);
		GridBagLayout layout = new GridBagLayout();
		positionPanel.setLayout(layout);
		
		Border line;
		TitledBorder tb;		
		
		gbc.gridwidth = 1;
		gbc.gridy = 0;
		positionPanel.add(connectionTypes, gbc);
			
		//Origin
		gbc.gridx = 0;
		gbc.gridy = 1;
		gbc.gridwidth = 1;
		positionPanel.add(new JLabel("Start Point:"), gbc);
		
		line = BorderFactory.createLineBorder(Color.gray, 0);
		gbc.gridx = 1;
		tb = BorderFactory.createTitledBorder(line, "x");
		tb.setTitleJustification(TitledBorder.CENTER);
		JPanel xPanel = new JPanel();
		xPanel.add(x);
		xPanel.setBorder(tb);
		positionPanel.add(xPanel, gbc);
		
		gbc.gridx = 2;
		tb = BorderFactory.createTitledBorder(line, "y");
		tb.setTitleJustification(TitledBorder.CENTER);
		JPanel yPanel = new JPanel();
		yPanel.add(y);
		yPanel.setBorder(tb);
		positionPanel.add(yPanel, gbc);
		
		gbc.gridx = 3;
		tb = BorderFactory.createTitledBorder(line, "z");
		tb.setTitleJustification(TitledBorder.CENTER);
		JPanel zPanel = new JPanel();
		zPanel.add(z);
		zPanel.setBorder(tb);
		positionPanel.add(zPanel, gbc);
		
		gbc.gridx = 4;
		gbc.gridheight = 2;
		gbc.gridwidth = 2;
		positionPanel.add(collisionCheck, gbc);
		
		//Dimensions
		gbc.gridwidth = 1;
		gbc.gridheight = 1;
		gbc.gridx = 0;
		gbc.gridy = 2;
		positionPanel.add(new JLabel("Dimensions:"), gbc);
		gbc.fill = GridBagConstraints.BOTH;
		gbc.weightx = 0;
		gbc.weighty = 1;
		
		gbc.gridx = 1;
		JPanel xDPanel = new JPanel();
		xDPanel.add(dimX);
		positionPanel.add(xDPanel, gbc);
		
		gbc.gridx = 2;
		JPanel yDPanel = new JPanel();
		yDPanel.add(dimY);
		positionPanel.add(yDPanel, gbc);
		
		gbc.gridx = 3;
		JPanel zDPanel = new JPanel();
		zDPanel.add(dimZ);
		positionPanel.add(zDPanel, gbc);
		
		gbc.gridy = 3;
		gbc.gridx = 0;
		positionPanel.add(new JLabel("Neurons:"), gbc);
		gbc.gridx = 1;
		positionPanel.add(numNeurons, gbc);
		
		gbc.gridx = 2;
		positionPanel.add(new JLabel("% Ex/In:"), gbc);
		gbc.gridx = 3;
		positionPanel.add(percentEx, gbc);
		
		this.add(positionPanel, superLay);
	}
	
	public void addActionListeners() {
		
		
		
	}
	
	
	
	
	
	
	
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		JFrame master = new JFrame();
		master.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		master.add(new LayerPropertiesPanel(), BorderLayout.CENTER);
		
		master.pack();
		master.setVisible(true);
		
		Integer [] poop = {1, 2, 3};
		Integer [] doop = {1, 2, 3};
		
		System.out.println(poop == doop);
		System.out.println(poop.equals(doop));
		System.out.println(Arrays.deepEquals(poop, doop));
		
	}

}
